package 蓝桥算法;

public class 闰年和日期的计算 {
    public static void main(String[] args) {
        //题目：在1901/1/1——2024/12/31__求：日期以1结尾的且当天是星期一
        //定义月份数组
        int[] monthArr = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
        //1901/1/1 当天为星期二
        int week = 2;
        int count = 0;//计数
        //for -年 -月 -天 
        for (int i = 1901; i <= 2024; i++) { //闰年判断 to 月
            for (int j = 1; j <= 12; j++) {
                int day = monthArr[j - 1];
                if (j == 2 && i % 4 == 0) {
                    day++;
                }//闰年
                for (int d = 1; d <= day; d++) {
                    if (d % 10 == 1 && week == 1) {
                        count++;
                        System.out.printf("%s/%s/%s",i,j,d);
                        System.out.println();
                    }
                    week = (week + 1) % 7;
                }
            }

        }System.out.println(count);
    }
}
